package com.aote.expression.paramprocessor;

import java.util.Map;

import com.aote.expression.Param;
import com.browsesoft.htmlcomponent.HTMLBasicComponent;
import com.browsesoft.user.User;

//取多个值中的最大值
public class MaxValueProcessor implements ParamProcessor {
	public String process(Param param, Map attributes, User loginUser,
			HTMLBasicComponent component) {
		Map map = param.getParams();
		String fields = (String) map.get("fields");
		//循环取多个字段中的最大值
		int max = 0;
		for(String field : fields.split(",")) {
			String sValue = (String)attributes.get(field);
			if(sValue != null && !sValue.equals("")) {
				int v = Integer.parseInt(sValue);
				if(v > max) {
					max = v;
				}
			}
		}
		return max + "";
	}
}
